home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / Menu.as < prev    next >
Text File  |  2013-04-24  |  5KB  |  142 lines

  1. class Menu extends PopUp
  2. {
  3.    static var sSOUND_STATE_ON = "SoundOn";
  4.    static var sSOUND_STATE_OFF = "SoundOff";
  5.    static var sMUSIC_STATE_ON = "MusicOn";
  6.    static var sMUSIC_STATE_OFF = "MusicOff";
  7.    static var sMENU_OPTIONS = "Options";
  8.    static var sMENU_QUIT = "Quit";
  9.    function Menu(_mcRef)
  10.    {
  11.       super(_mcRef);
  12.    }
  13.    function doShow()
  14.    {
  15.       if(this.sState == PopUp.sSTATE_IDLE)
  16.       {
  17.          this.setState(PopUp.sSTATE_OPENING);
  18.          Controller.getRef().getSounds().playSound("Menu_In",Controller.nSFX_VOLUME,1);
  19.          this.updateSoundButton();
  20.          this.updateMusicButton();
  21.          Controller.getRef().pauseGame();
  22.       }
  23.    }
  24.    function doHide()
  25.    {
  26.       if(this.sState == PopUp.sSTATE_OPENED)
  27.       {
  28.          this.setState(PopUp.sSTATE_CLOSING);
  29.          Controller.getRef().getSounds().playSound("Menu_Out",Controller.nSFX_VOLUME,1);
  30.          this.updateSoundButton();
  31.          this.updateMusicButton();
  32.          Controller.getRef().unPauseGame();
  33.       }
  34.    }
  35.    function clickSoundButton()
  36.    {
  37.       Controller.getRef().playClickSound();
  38.       if(Controller.getRef().isSoundsMuted())
  39.       {
  40.          Controller.getRef().unMuteSounds();
  41.       }
  42.       else
  43.       {
  44.          Controller.getRef().muteSounds();
  45.       }
  46.       this.updateSoundButton();
  47.    }
  48.    function clickMusicButton()
  49.    {
  50.       Controller.getRef().playClickSound();
  51.       if(Controller.getRef().isMusicMuted())
  52.       {
  53.          Controller.getRef().unMuteMusic();
  54.       }
  55.       else
  56.       {
  57.          Controller.getRef().muteMusic();
  58.       }
  59.       this.updateMusicButton();
  60.    }
  61.    function resume()
  62.    {
  63.       Controller.getRef().playClickSound();
  64.       this.doHide();
  65.    }
  66.    function updateSoundButton()
  67.    {
  68.       if(Controller.getRef().isSoundsMuted())
  69.       {
  70.          this.mcRef.mcState.mcPanel.mcSound.gotoAndStop(Menu.sSOUND_STATE_OFF);
  71.       }
  72.       else
  73.       {
  74.          this.mcRef.mcState.mcPanel.mcSound.gotoAndStop(Menu.sSOUND_STATE_ON);
  75.       }
  76.       this.mcRef.mcState.mcPanel.mcSound.btnSound.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  77.       this.mcRef.mcState.mcPanel.mcSound.btnSound.onRelease = Delegate.create(this,this.clickSoundButton);
  78.    }
  79.    function updateMusicButton()
  80.    {
  81.       if(Controller.getRef().isMusicMuted())
  82.       {
  83.          this.mcRef.mcState.mcPanel.mcMusic.gotoAndStop(Menu.sMUSIC_STATE_OFF);
  84.       }
  85.       else
  86.       {
  87.          this.mcRef.mcState.mcPanel.mcMusic.gotoAndStop(Menu.sMUSIC_STATE_ON);
  88.       }
  89.       this.mcRef.mcState.mcPanel.mcMusic.btnMusic.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  90.       this.mcRef.mcState.mcPanel.mcMusic.btnMusic.onRelease = Delegate.create(this,this.clickMusicButton);
  91.    }
  92.    function gotoQuitMenu()
  93.    {
  94.       Controller.getRef().playClickSound();
  95.       this.showQuitMenu();
  96.    }
  97.    function gotoOptionsMenu()
  98.    {
  99.       Controller.getRef().playClickSound();
  100.       this.showOptionsMenu();
  101.    }
  102.    function showOptionsMenu()
  103.    {
  104.       this.mcRef.mcState.gotoAndStop(Menu.sMENU_OPTIONS);
  105.       this.updateSoundButton();
  106.       this.updateMusicButton();
  107.       this.mcRef.mcState.mcPanel.btnResume.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  108.       this.mcRef.mcState.mcPanel.btnResume.onRelease = Delegate.create(this,this.resume);
  109.       this.mcRef.mcState.mcPanel.btnHowToPlay.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  110.       this.mcRef.mcState.mcPanel.btnHowToPlay.onRelease = Delegate.create(Main.getRef(),Main.getRef().clickInstructionsButton);
  111.       this.mcRef.mcState.mcPanel.btnQuit.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  112.       this.mcRef.mcState.mcPanel.btnQuit.onRelease = Delegate.create(this,this.gotoQuitMenu);
  113.    }
  114.    function showQuitMenu()
  115.    {
  116.       Controller.getRef().playClickSound();
  117.       this.mcRef.mcState.gotoAndStop(Menu.sMENU_QUIT);
  118.       this.mcRef.mcState.mcPanel.btnYes.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  119.       this.mcRef.mcState.mcPanel.btnNo.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  120.       this.mcRef.mcState.mcPanel.btnYes.onRelease = Delegate.create(Main.getRef(),Main.getRef().clickQuitButton);
  121.       this.mcRef.mcState.mcPanel.btnNo.onRelease = Delegate.create(this,this.gotoOptionsMenu);
  122.    }
  123.    function Opening()
  124.    {
  125.       if(this.stateFinished())
  126.       {
  127.          this.setState(PopUp.sSTATE_OPENED);
  128.          this.showOptionsMenu();
  129.       }
  130.    }
  131.    function Opened()
  132.    {
  133.    }
  134.    function Closing()
  135.    {
  136.       if(this.stateFinished())
  137.       {
  138.          this.setState(PopUp.sSTATE_IDLE);
  139.       }
  140.    }
  141. }
  142.